﻿using IntelligentAgriculture.Contracts.Interface.SheepFileModelInterface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepfilemodelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepfilemodelCommandHandler
{
    /// <summary>
	/// 根据繁殖状态和在场状态获取耳号
	/// </summary>
    public class GetReproductionStateCommandHandler : IRequestHandler<GetReproductionStateCommand,Results<IQueryable<Sheepfilemodel>>>
    {


        private readonly ISheepFileModelService _sheepFileModelService;
        public GetReproductionStateCommandHandler(ISheepFileModelService sheepFileModelService)
        {
            _sheepFileModelService = sheepFileModelService;
        }




        public async Task<Results<IQueryable<Sheepfilemodel>>> Handle(GetReproductionStateCommand request, CancellationToken cancellationToken)
        {
            var result = await _sheepFileModelService.GetReproductionState(request.presentState, request.sheepType);
            return Results<IQueryable<Sheepfilemodel>>.DataResult(result);
        }
    }
}
